package service;

import model.Hobby;
import model.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import repository.HobbyRepository;
import repository.UserRepository;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserService {

    protected final Logger log = LoggerFactory.getLogger(getClass());

    @Autowired
    private UserRepository userRepository;

    public boolean isUserNameAndFirstNameExists(User user) {

        if ((user != null) && (user.getName() != null) && (user.getFirstName() != null)) {

            List<User> userList = userRepository.getUsersByNameAndFirstName(user.getName(), user.getFirstName());

            if (userList == null)
                return false;

            return !userList.isEmpty();
        }

        return false;
    }
}
